package demo04;

public class Computer {
    public void powerOn(){
        System.out.println("打开电脑...");
    }
    public void powerOff(){
        System.out.println("关闭电脑...");
    }
    public void useDevice(IUSB iusb){
        if (iusb instanceof keyBoard){
//            iusb.input(); //由于 iusb 当中没有 input 这个方法 ,
//            ((keyBoard)iusb).input();//强制转化后发现可以调用
            keyBoard keyBoard = (demo04.keyBoard) iusb;
            keyBoard.input();
        }
        if (iusb instanceof Mouse){
            Mouse mouse = (Mouse)iusb;
            mouse.click();
        }
    }
}
